<template>
	<view>
		<u-navbar :background="background" :borderBottom="false">
			<view class="ft_16 fw-b">
				我的收藏
			</view>
		</u-navbar>
		<view class="content">
			<view class="options display">
				<!-- <view class="option" @click="options(0)">
					<text style="padding-right: 5px;">默认排序</text>
					<u-icon name="arrow-down-fill" color="#999999" size="20" v-if="option"></u-icon>
					<u-icon name="arrow-up-fill" color="#999999" size="20" v-else></u-icon>
				</view>
				<view class="option" @click="options(1)">
					<text style="padding-right: 5px;">销量</text>
					<u-icon name="arrow-down-fill" color="#999999" size="20" v-if="option1"></u-icon>
					<u-icon name="arrow-up-fill" color="#999999" size="20" v-else></u-icon>
				</view>
				<view class="option" @click="options(2)">
					<text style="padding-right: 5px;">价格</text>
					<u-icon name="arrow-down-fill" color="#999999" size="20" v-if="option2"></u-icon>
					<u-icon name="arrow-up-fill" color="#999999" size="20" v-else></u-icon>
				</view> -->
			</view>
			<u-waterfall v-model="shopList">
				<template v-slot:left="{leftList}">
					<view class="" v-for="(item,index) in leftList" :key="index">
						<shop v-if="item.type_switch!=4" :shopimg="item.image" :shopname="item.name" :oldprice="item.market_price" :newprice="item.prices" :yuexiao="item.sales" @click.native="go_shopList(item)"></shop>
						<!-- 积分商品 -->
						<shop1 v-else :shopimg="item.image" :shopname="item.name" :price="item.price" :jifen="item.prices" :num="item.sales" @click.native="go_shopList(item,index)"></shop1>
					</view>
				</template>
				<template v-slot:right="{rightList}">
					<view class="display" style="align-items: flex-end;flex-flow: column;">
						<view class="" v-for="(item,index) in rightList" :key="index">
							<shop v-if="item.type_switch!=4" :shopimg="item.image" :shopname="item.name" :oldprice="item.market_price" :newprice="item.prices" :yuexiao="item.sales" @click.native="go_shopList(item)"></shop>
							<!-- 积分商品 -->
							<shop1 v-else :shopimg="item.image" :shopname="item.name" :price="item.price" :jifen="item.prices" :num="item.sales" @click.native="go_shopList(item,index)"></shop1>
						</view>
					</view>
				</template>
			</u-waterfall>
			<!-- <view class="display just_space tuijian" style="flex-flow: wrap;">
				<view class="" v-for="(item,index) in shopList" :key="index">
					<shop v-if="item.type_switch!=4" :shopimg="item.image" :shopname="item.name" :oldprice="item.market_price" :newprice="item.prices" :yuexiao="item.sales" @click.native="go_shopList(item)"></shop> -->
					<!-- 积分商品 -->
					<!-- <shop1 v-else :shopimg="item.image" :shopname="item.name" :price="item.price" :jifen="item.prices" :num="item.sales" @click.native="go_shopList(item,index)"></shop1>
				</view>
			</view> -->
			
		</view>
		
	</view>
</template>

<script>
	import shop from "@/components/shop.vue"
	import shop1 from "@/components/jifenShop.vue"
	export default {
		data() {
			return {
				background:{backgroundColor: '#fafafa',},
				option:true, //默认排序
				option1:true, //销量排序
				option2:true, //价格排序
				
				shopList:[], //商品列表
				
			}
		},
		components:{
			shop,shop1
		},
		onLoad() {
			this.getshopList() //获取商品列表
		},
		methods: {
			getshopList(){ //获取商品列表
				this.$myRequest('user/collectionList',{})
				.then(res=>{
					console.log(res.data.data);
					if(res.data.code==1){
						let data=res.data.data
						if(data.site.length>0){
							this.shopList.push(...data.site)
						}
						console.log(this.shopList);
						let user=this.$all.getData('userInfo').role_type //获取用户信息
						this.shopList.forEach(i=>{
							if(i.type_switch!=4){
								i.prices= user==0 ? i.prices : user==1 ? i.prices1 : user==2 ? i.prices2 :i.prices3
							}else{ //积分商品
								i.price= user==0 ? i.price : user==1 ? i.price1 : user==2 ? i.price2 :i.price3
							}
						})
					}
				})
			},
			go_shopList(item,index){ //去商品详情
				console.log(item.type_switch);
				if(item.type_switch==1||item.type_switch==5){ //普通 虚拟 商品 
					uni.navigateTo({
						url:"../../../../pages/shop/shopDetail?shopid="+item.id
					})
				}else if(item.type_switch==2){ //秒杀商品
					uni.navigateTo({
						url:"../../index/miaosha/miaoshaDetail?shopid="+item.id
					})
				}else if(item.type_switch==3){ //团购商品
					uni.navigateTo({
						url:"../../index/pindan/pindanDetail?shopid="+item.id
					})
				}else if(item.type_switch==4){ //积分商品
					uni.navigateTo({
						url:"../../index/jifen/jifenDetail?shopid="+item.id
					})
				}else{ //虚拟商品
					
				}
			},
			
		}
	}
</script>

<style lang="scss">
page{
	background-color: #fafafa;
}
.content{
	padding: 0 15px;
	.options{
		padding: 10px 0;
		.option{
			padding-right: 25px;
		}
	}
}

</style>
